<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head>


<title>
		The Bakery, Everything CakePHP : Leafs</title>
<link rel="icon" href="http://bakery.cakephp.org/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="http://bakery.cakephp.org/favicon.ico" type="image/x-icon">
<link rel="alternate" type="application/rss+xml" title="The Bakery : 15 most recent articles" href="http://bakery.cakephp.org/articles/rss">
<link rel="alternate" type="application/rss+xml" title="The Bakery : 15 most recent comments" href="http://bakery.cakephp.org/comments.rss">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><link rel="stylesheet" type="text/css" href="Authenticate_from_cookie_files/cake.css" media="all"><link rel="stylesheet" type="text/css" href="Authenticate_from_cookie_files/cake_002.css" media="all">
<script type="text/javascript" src="Authenticate_from_cookie_files/prototype.js"></script><script type="text/javascript" src="Authenticate_from_cookie_files/effects.js"></script><script type="text/javascript" src="Authenticate_from_cookie_files/bakery.js"></script><script src="Authenticate_from_cookie_files/urchin.js" type="text/javascript"></script>
 <script type="text/javascript">
         _uacct = "UA-743287-1";
         urchinTracker();
 </script>
</head><body class="fp">
  <div id="container">

	  <div class="tortillated" id="accountMenu">
	<ul>
		<li><a href="http://bakery.cakephp.org/">Home</a></li>
		<li><a href="http://bakery.cakephp.org/users/login">Login</a></li>
		<li><a href="http://bakery.cakephp.org/users/register">Register</a></li>
	</ul>
<div class="top_left corner"></div><div class="top_right corner"></div><div class="bottom_left corner"></div><div class="bottom_right corner"></div></div>
	  <div id="header">
		  <a href="http://bakery.cakephp.org/"><h1>The Bakery <span>Everything CakePHP</span></h1></a>
		</div>

		
<div class="tortillated" id="tabs">
	<ul>
				<li><a href="http://bakery.cakephp.org/categories/view/1" class="">News</a></li>

				<li><a href="http://bakery.cakephp.org/categories/view/2" class="">Articles</a></li>

				<li><a href="http://bakery.cakephp.org/categories/view/3" class="">Code</a></li>
	</ul>
<div class="top_left corner"></div><div class="top_right corner"></div><div class="bottom_left corner"></div><div class="bottom_right corner"></div></div>

<div id="search">
	<form id="SearchForm" method="post" action="/articles/search"><p style="margin: 0px; padding: 0px; display: inline;"><input name="data[__Token][key]" value="72b3017baacd1a8a0aff2013a7a5bd71e9394eac" id="SearchFormToken1490178240" type="hidden"></p>		<input name="data[Search][words]" size="16" value="" id="SearchWords" type="text">		<select name="data[Search][type]" id="SearchType">
<option value="tags">Tags</option>
<option value="1">News</option>
<option value="2">Articles</option>
<option value="3">Code</option>
</select>	<p style="margin: 0px; padding: 0px; display: inline;"><input name="data[__Token][fields]" value="501720d00318f4529495d467e4d438be368d3e2d" id="TokenFields1869048553" type="hidden"></p></form></div>
		

		<div id="content">
				    	
<div id="article" class="published">

	<h2>
		<a href="http://bakery.cakephp.org/articles/view/darkauth-another-way">DarkAuth - another way...</a>	</h2>
	
	<h3>
		2 : The Component Code	</h3>
	
	<div id="sidebar">

	  	<div id="article_badges">
			<span class="components badge"> <a href="http://bakery.cakephp.org/categories/view/7">Components</a></span>
			<span class="date"> 02/18/2008 </span>		</div>
	
		<div id="article_details" class="info tortillated">
	  		<ul>
	  			
	  			
	  			<li>version: 1.2 beta</li>

	  			<li>views: 4381</li>

	  				  				<li><a href="http://bakery.cakephp.org/articles/view/darkauth-another-way#comments">comments (15)</a></li>
	  				  		</ul>
	  	<div class="top_left corner"></div><div class="top_right corner"></div><div class="bottom_left corner"></div><div class="bottom_right corner"></div></div>
	
		<div id="ajax_rate" class="info tortillated">
			<div id="article_rating">
	<h4>rating</h4>
		
	
		<ul>
			<li><a href="http://bakery.cakephp.org/articles/rate/617">Login to add rating</a></li>
		</ul>
	</div>		<div class="top_left corner"></div><div class="top_right corner"></div><div class="bottom_left corner"></div><div class="bottom_right corner"></div></div>

		<div id="ajax_tag" class="info tortillated">
			<div id="article_tags">
	<h4>tags</h4>
	
			<ul id="add_tag_button" class="actions">
			<li><a href="http://bakery.cakephp.org/articles/tag/617">Login to add tags</a></li>
		</ul>
	</div>		<div class="top_left corner"></div><div class="top_right corner"></div><div class="bottom_left corner"></div><div class="bottom_right corner"></div></div>

	  	
					<div class="info tortillated">
				<h4>more</h4>
				<ul>
					<li><a href="http://bakery.cakephp.org/articles/view/darkauth-another-way">Page 1: DarkAuth - another way...</a></li>
											<li><a href="http://bakery.cakephp.org/leafs/view/41">Page 2: The Component Code</a></li>
											<li><a href="http://bakery.cakephp.org/leafs/view/42">Page 3: 5 Steps to Setup (well, maybe 6)</a></li>
							   </ul><div class="top_left corner"></div><div class="top_right corner"></div><div class="bottom_left corner"></div><div class="bottom_right corner"></div></div>
		
	</div> <!-- /sidebar -->
	
	
	<div class="main">
	
		<span class="author">
	    	By <a href="http://bakery.cakephp.org/users/view/theChrisWalker">Chris Walker</a>	  	</span>
	
		<div class="intro">
I wrote this initially for Cake 1.1 - basing it on ideas from "obAuth"
by Steve Oliveira, but upgraded it to 1.2 rather than using the built
in Auth component, mostly because this works how I want it to and, once
setup, is really easy to use.<br>
<br>
Main Features:<br>
<br>
 - Per action / per controller / inline access control<br>
 - Optional Group support for HABTM and User BelongsTo Group associations<br>
 - A "super-user" functionality allowing one group automatic access granted<br>
 - Optional tamper-proof Cookie support<br>
 - Custom password hashing to suit your Model<br>
		</div>
	
		<div class="body">
		
			So here's the code for the component, it's quite a chunk, then on the next page I'll describe the setup.<br>
<br>
<h4><strong>Component Class:</strong></h4><code><span style="color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 187);">&lt;?php&nbsp;
<br></span><span style="color: rgb(0, 119, 0);">class&nbsp;</span><span style="color: rgb(0, 0, 187);">DarkAuthComponent&nbsp;</span><span style="color: rgb(0, 119, 0);">extends&nbsp;</span><span style="color: rgb(0, 0, 187);">Object&nbsp;</span><span style="color: rgb(0, 119, 0);">{
<br>
<br>&nbsp;&nbsp;var&nbsp;</span><span style="color: rgb(0, 0, 187);">$user_model_name&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(221, 0, 0);">'User'</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;var&nbsp;</span><span style="color: rgb(0, 0, 187);">$users_controller_name&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(221, 0, 0);">'Users'</span><span style="color: rgb(0, 119, 0);">;&nbsp;
<br>&nbsp;&nbsp;var&nbsp;</span><span style="color: rgb(0, 0, 187);">$user_name_field&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(221, 0, 0);">'email'</span><span style="color: rgb(0, 119, 0);">;&nbsp;</span><span style="color: rgb(255, 128, 0);">//e.g.&nbsp;email&nbsp;or&nbsp;firstname&nbsp;or&nbsp;username...
<br>&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">var&nbsp;</span><span style="color: rgb(0, 0, 187);">$user_name_case_folding&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(221, 0, 0);">'lower'</span><span style="color: rgb(0, 119, 0);">;&nbsp;</span><span style="color: rgb(255, 128, 0);">//do&nbsp;you&nbsp;want&nbsp;to&nbsp;case&nbsp;fold&nbsp;the&nbsp;username&nbsp;before&nbsp;verifying?&nbsp;either&nbsp;'lower','upper','none',&nbsp;to&nbsp;change&nbsp;case&nbsp;to&nbsp;lower/upper/leave&nbsp;it&nbsp;alone&nbsp;before&nbsp;matching.
<br>&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">var&nbsp;</span><span style="color: rgb(0, 0, 187);">$user_pass_field&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(221, 0, 0);">'password'</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;var&nbsp;</span><span style="color: rgb(0, 0, 187);">$user_live_field&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(221, 0, 0);">'live'</span><span style="color: rgb(0, 119, 0);">;&nbsp;</span><span style="color: rgb(255, 128, 0);">//&nbsp;surely&nbsp;you&nbsp;have&nbsp;a&nbsp;field&nbsp;in&nbsp;you&nbsp;users&nbsp;table&nbsp;to&nbsp;show&nbsp;whether&nbsp;the&nbsp;user&nbsp;is&nbsp;active&nbsp;or&nbsp;not?&nbsp;set&nbsp;to&nbsp;null&nbsp;if&nbsp;not.
<br>&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">var&nbsp;</span><span style="color: rgb(0, 0, 187);">$user_live_value&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">1</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;var&nbsp;</span><span style="color: rgb(0, 0, 187);">$group_model_name&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(221, 0, 0);">'Group'</span><span style="color: rgb(0, 119, 0);">;&nbsp;</span><span style="color: rgb(255, 128, 0);">//Group&nbsp;for&nbsp;access&nbsp;control&nbsp;if&nbsp;used.&nbsp;NB:&nbsp;DON'T&nbsp;CALL&nbsp;requiresAuth&nbsp;with&nbsp;Groups&nbsp;if&nbsp;no&nbsp;group&nbsp;model.&nbsp;it&nbsp;will&nbsp;error.
<br>&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">var&nbsp;</span><span style="color: rgb(0, 0, 187);">$group_name_field&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(221, 0, 0);">'name'</span><span style="color: rgb(0, 119, 0);">;&nbsp;</span><span style="color: rgb(255, 128, 0);">//&nbsp;the&nbsp;name&nbsp;of&nbsp;the&nbsp;field&nbsp;used&nbsp;for&nbsp;the&nbsp;groups&nbsp;name.&nbsp;This&nbsp;will&nbsp;be&nbsp;used&nbsp;to&nbsp;check&nbsp;against&nbsp;passed&nbsp;groups.
<br>&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">var&nbsp;</span><span style="color: rgb(0, 0, 187);">$HABTM&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">true</span><span style="color: rgb(0, 119, 0);">;&nbsp;</span><span style="color: rgb(255, 128, 0);">//set&nbsp;to&nbsp;false&nbsp;if&nbsp;you&nbsp;don&nbsp;use&nbsp;a&nbsp;HABTM&nbsp;group&nbsp;relationship.
<br>&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">var&nbsp;</span><span style="color: rgb(0, 0, 187);">$superuser_group&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(221, 0, 0);">'Root'</span><span style="color: rgb(0, 119, 0);">;&nbsp;</span><span style="color: rgb(255, 128, 0);">//if&nbsp;you&nbsp;want&nbsp;a&nbsp;single&nbsp;group&nbsp;to&nbsp;have&nbsp;automatically&nbsp;granted&nbsp;access&nbsp;to&nbsp;any&nbsp;restriction.
<br>&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">var&nbsp;</span><span style="color: rgb(0, 0, 187);">$login_view&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(221, 0, 0);">'/login'</span><span style="color: rgb(0, 119, 0);">;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//this&nbsp;is&nbsp;the&nbsp;login&nbsp;view,&nbsp;usually&nbsp;{user_controller}/login&nbsp;but&nbsp;you&nbsp;may&nbsp;have&nbsp;changed&nbsp;the&nbsp;routes.
<br>&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">var&nbsp;</span><span style="color: rgb(0, 0, 187);">$deny_view&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(221, 0, 0);">'/deny'</span><span style="color: rgb(0, 119, 0);">;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//this&nbsp;is&nbsp;the&nbsp;default&nbsp;denied&nbsp;access&nbsp;view.
<br>&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">var&nbsp;</span><span style="color: rgb(0, 0, 187);">$logout_page&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(221, 0, 0);">'/'</span><span style="color: rgb(0, 119, 0);">;&nbsp;</span><span style="color: rgb(255, 128, 0);">//&nbsp;NB&nbsp;this&nbsp;is&nbsp;were&nbsp;to&nbsp;redirect&nbsp;AFTER&nbsp;logout&nbsp;by&nbsp;default
<br>&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">var&nbsp;</span><span style="color: rgb(0, 0, 187);">$login_failed_message&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(221, 0, 0);">'&lt;p&nbsp;class="error"&gt;Login&nbsp;Failed,&nbsp;Please&nbsp;check&nbsp;your&nbsp;details&nbsp;and&nbsp;try&nbsp;again.&lt;/p&gt;'</span><span style="color: rgb(0, 119, 0);">;&nbsp;</span><span style="color: rgb(255, 128, 0);">//This&nbsp;message&nbsp;is&nbsp;setFlash()'d&nbsp;on&nbsp;failed&nbsp;login.
<br>&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">var&nbsp;</span><span style="color: rgb(0, 0, 187);">$allow_cookie&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">true</span><span style="color: rgb(0, 119, 0);">;&nbsp;</span><span style="color: rgb(255, 128, 0);">//Allow&nbsp;use&nbsp;of&nbsp;cookies&nbsp;to&nbsp;remember&nbsp;authenticated&nbsp;sessions.
<br>&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">var&nbsp;</span><span style="color: rgb(0, 0, 187);">$cookie_expiry&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(221, 0, 0);">'+6&nbsp;Months'</span><span style="color: rgb(0, 119, 0);">;&nbsp;</span><span style="color: rgb(255, 128, 0);">//how&nbsp;long&nbsp;until&nbsp;cookies&nbsp;expire.&nbsp;format&nbsp;is&nbsp;"strtotime()"&nbsp;based&nbsp;(http://php.net/strtotime).
<br>&nbsp;&nbsp;&nbsp;&nbsp;//var&nbsp;$session_secure_key&nbsp;=&nbsp;'sRmtVStkedAdlxBy';&nbsp;//some&nbsp;random&nbsp;stuff&nbsp;that&nbsp;someone&nbsp;is&nbsp;unlikey&nbsp;to&nbsp;guess.&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">var&nbsp;</span><span style="color: rgb(0, 0, 187);">$session_secure_key&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(221, 0, 0);">'sJfkgD420YsfhC2k4Abs'</span><span style="color: rgb(0, 119, 0);">;
<br>
<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">/*
<br>&nbsp;&nbsp;&nbsp;*&nbsp;You&nbsp;can&nbsp;edit&nbsp;this&nbsp;function&nbsp;to&nbsp;explain&nbsp;how&nbsp;you&nbsp;want&nbsp;to&nbsp;hash&nbsp;your&nbsp;passwords.
<br>&nbsp;&nbsp;&nbsp;*/
<br>&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">function&nbsp;</span><span style="color: rgb(0, 0, 187);">hasher</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$plain_text</span><span style="color: rgb(0, 119, 0);">){
<br>
<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$hashed&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">md5</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">'dark'</span><span style="color: rgb(0, 119, 0);">.</span><span style="color: rgb(0, 0, 187);">$plain_text</span><span style="color: rgb(0, 119, 0);">.</span><span style="color: rgb(221, 0, 0);">'cake'</span><span style="color: rgb(0, 119, 0);">);
<br>
<br>&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: rgb(0, 0, 187);">$hashed</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;}
<br>
<br></span><span style="color: rgb(255, 128, 0);">##########################################################################
<br>&nbsp;/*
<br>&nbsp;&nbsp;*&nbsp;DON'T&nbsp;EDIT&nbsp;THESE&nbsp;OR&nbsp;ANYTHING&nbsp;BELOW&nbsp;HERE&nbsp;UNLESS&nbsp;YOU&nbsp;KNOW&nbsp;WHAT&nbsp;YOU'RE&nbsp;DOING
<br>&nbsp;&nbsp;*/
<br>&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">var&nbsp;</span><span style="color: rgb(0, 0, 187);">$controller</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;var&nbsp;</span><span style="color: rgb(0, 0, 187);">$here</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;var&nbsp;</span><span style="color: rgb(0, 0, 187);">$components</span><span style="color: rgb(0, 119, 0);">=array(</span><span style="color: rgb(221, 0, 0);">'Session'</span><span style="color: rgb(0, 119, 0);">);
<br>&nbsp;&nbsp;var&nbsp;</span><span style="color: rgb(0, 0, 187);">$current_user</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;var&nbsp;</span><span style="color: rgb(0, 0, 187);">$from_session</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;var&nbsp;</span><span style="color: rgb(0, 0, 187);">$from_post</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;var&nbsp;</span><span style="color: rgb(0, 0, 187);">$from_cookie</span><span style="color: rgb(0, 119, 0);">;
<br>
<br>&nbsp;&nbsp;function&nbsp;</span><span style="color: rgb(0, 0, 187);">startup</span><span style="color: rgb(0, 119, 0);">(&amp;</span><span style="color: rgb(0, 0, 187);">$controller</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//Let's&nbsp;check&nbsp;they&nbsp;have&nbsp;changed&nbsp;the&nbsp;secure&nbsp;key&nbsp;from&nbsp;the&nbsp;default.
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">if(</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">session_secure_key&nbsp;</span><span style="color: rgb(0, 119, 0);">==&nbsp;</span><span style="color: rgb(221, 0, 0);">'sRmtVStkedAdlxBy'</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;die(</span><span style="color: rgb(221, 0, 0);">'&lt;p&gt;Please&nbsp;change&nbsp;the&nbsp;DarkAuth::session_secure_key&nbsp;value&nbsp;from&nbsp;it&nbsp;default.&lt;/p&gt;'</span><span style="color: rgb(0, 119, 0);">);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">controller&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">$controller</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">here&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">substr</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$controller</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">here</span><span style="color: rgb(0, 119, 0);">,</span><span style="color: rgb(0, 0, 187);">strlen</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$controller</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">base</span><span style="color: rgb(0, 119, 0);">));
<br>&nbsp;&nbsp;&nbsp;&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">controller</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">_login</span><span style="color: rgb(0, 119, 0);">();
<br>&nbsp;&nbsp;&nbsp;&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//now&nbsp;check&nbsp;session/cookie&nbsp;info.
<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">getUserInfoFromSessionOrCookie</span><span style="color: rgb(0, 119, 0);">();
<br>
<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//now&nbsp;see&nbsp;if&nbsp;the&nbsp;calling&nbsp;controller&nbsp;wants&nbsp;auth&nbsp;(except&nbsp;for&nbsp;the&nbsp;users/login&nbsp;or&nbsp;logout&nbsp;or&nbsp;deny&nbsp;actions)
<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">if(&nbsp;</span><span style="color: rgb(0, 0, 187);">array_key_exists</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">'DarkAuth_requiresAuth'</span><span style="color: rgb(0, 119, 0);">,&nbsp;</span><span style="color: rgb(0, 0, 187);">$controller</span><span style="color: rgb(0, 119, 0);">)&nbsp;){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//&nbsp;We&nbsp;want&nbsp;Auth&nbsp;for&nbsp;any&nbsp;action&nbsp;here
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">if(</span><span style="color: rgb(0, 0, 187);">array_key_exists</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">'DarkAuth_ifAccessDenied'</span><span style="color: rgb(0, 119, 0);">,</span><span style="color: rgb(0, 0, 187);">$controller</span><span style="color: rgb(0, 119, 0);">)){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$deny&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">$controller</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">DarkAuth_ifAccessDenied</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}else{
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$deny&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">null</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">requiresAuth</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$controller</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">DarkAuth_requiresAuth</span><span style="color: rgb(0, 119, 0);">,</span><span style="color: rgb(0, 0, 187);">$deny</span><span style="color: rgb(0, 119, 0);">);
<br>&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//finally&nbsp;give&nbsp;the&nbsp;view&nbsp;access&nbsp;to&nbsp;the&nbsp;data
<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">controller</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">set</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">'DarkAuth_User'</span><span style="color: rgb(0, 119, 0);">,</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">getUserInfo</span><span style="color: rgb(0, 119, 0);">());
<br>&nbsp;&nbsp;}
<br>
<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: rgb(0, 0, 187);">secure_key</span><span style="color: rgb(0, 119, 0);">(){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;</span><span style="color: rgb(0, 0, 187);">$key</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!</span><span style="color: rgb(0, 0, 187);">$key</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$key&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">md5</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">Configure</span><span style="color: rgb(0, 119, 0);">::</span><span style="color: rgb(0, 0, 187);">read</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">'Security.salt'</span><span style="color: rgb(0, 119, 0);">).</span><span style="color: rgb(221, 0, 0);">'!DarkAuth!'</span><span style="color: rgb(0, 119, 0);">.</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">session_secure_key</span><span style="color: rgb(0, 119, 0);">);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: rgb(0, 0, 187);">$key</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;}
<br>
<br>&nbsp;&nbsp;function&nbsp;</span><span style="color: rgb(0, 0, 187);">requiresAuth</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$groups</span><span style="color: rgb(0, 119, 0);">=array(),</span><span style="color: rgb(0, 0, 187);">$deny_redirect</span><span style="color: rgb(0, 119, 0);">=</span><span style="color: rgb(0, 0, 187);">null</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(&nbsp;empty(</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">current_user</span><span style="color: rgb(0, 119, 0);">)&nbsp;){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//&nbsp;Still&nbsp;no&nbsp;info!&nbsp;render&nbsp;logion&nbsp;page!
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">if(</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">from_post</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">Session</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">setFlash</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">login_failed_message</span><span style="color: rgb(0, 119, 0);">);&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">controller</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">render</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">login_view</span><span style="color: rgb(0, 119, 0);">);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit();
<br>&nbsp;&nbsp;&nbsp;&nbsp;}else{
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">from_post</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//&nbsp;user&nbsp;just&nbsp;authed,&nbsp;so&nbsp;redirect&nbsp;to&nbsp;avoid&nbsp;post&nbsp;data&nbsp;refresh.
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">controller</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">redirect</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">here</span><span style="color: rgb(0, 119, 0);">);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit();
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//&nbsp;User&nbsp;is&nbsp;authenticated,&nbsp;so&nbsp;we&nbsp;just&nbsp;need&nbsp;to&nbsp;check&nbsp;against&nbsp;the&nbsp;groups.
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">if(&nbsp;empty(</span><span style="color: rgb(0, 0, 187);">$groups</span><span style="color: rgb(0, 119, 0);">)&nbsp;){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//&nbsp;No&nbsp;Groups&nbsp;specified&nbsp;so&nbsp;we&nbsp;are&nbsp;good&nbsp;to&nbsp;go!
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$deny&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">false</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}else{
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$deny&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;!</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">isAllowed</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$groups</span><span style="color: rgb(0, 119, 0);">);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span style="color: rgb(0, 0, 187);">$deny</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//&nbsp;Current&nbsp;User&nbsp;Doesn't&nbsp;Have&nbsp;Access!&nbsp;DENY
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">if(</span><span style="color: rgb(0, 0, 187);">$deny_redirect</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">controller</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">redirect</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$deny_redirect</span><span style="color: rgb(0, 119, 0);">);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit();
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}else{
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">controller</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">render</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">deny_view</span><span style="color: rgb(0, 119, 0);">);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit();
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: rgb(0, 0, 187);">true</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;}
<br>&nbsp;
<br>&nbsp;&nbsp;function&nbsp;</span><span style="color: rgb(0, 0, 187);">isAllowed</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$groups</span><span style="color: rgb(0, 119, 0);">=array()){
<br>&nbsp;&nbsp;&nbsp;&nbsp;if(&nbsp;empty(</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">current_user</span><span style="color: rgb(0, 119, 0);">)&nbsp;){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//&nbsp;No&nbsp;information&nbsp;about&nbsp;the&nbsp;user!&nbsp;FALSE
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">return&nbsp;</span><span style="color: rgb(0, 0, 187);">false</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;}else{
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//&nbsp;User&nbsp;is&nbsp;authenticated,&nbsp;so&nbsp;we&nbsp;just&nbsp;need&nbsp;to&nbsp;check&nbsp;against&nbsp;the&nbsp;groups.
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">if(!</span><span style="color: rgb(0, 0, 187);">is_array</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$groups</span><span style="color: rgb(0, 119, 0);">)){&nbsp;</span><span style="color: rgb(0, 0, 187);">$groups</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(0, 0, 187);">0</span><span style="color: rgb(0, 119, 0);">]&nbsp;=&nbsp;</span><span style="color: rgb(0, 0, 187);">$groups</span><span style="color: rgb(0, 119, 0);">;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(&nbsp;empty(</span><span style="color: rgb(0, 0, 187);">$groups</span><span style="color: rgb(0, 119, 0);">)&nbsp;){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//&nbsp;No&nbsp;Groups&nbsp;specified&nbsp;so&nbsp;we&nbsp;are&nbsp;good&nbsp;to&nbsp;go!&nbsp;TRUE
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">return&nbsp;</span><span style="color: rgb(0, 0, 187);">true</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}else{
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//first&nbsp;check&nbsp;superuser&nbsp;access.
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">if(</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">superuser_group</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">array_unshift</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$groups</span><span style="color: rgb(0, 119, 0);">,</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">superuser_group</span><span style="color: rgb(0, 119, 0);">);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//&nbsp;Check&nbsp;each&nbsp;group.
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">if(!</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">HABTM</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//&nbsp;Single&nbsp;relation&nbsp;ship.
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">foreach(</span><span style="color: rgb(0, 0, 187);">$groups&nbsp;</span><span style="color: rgb(0, 119, 0);">as&nbsp;</span><span style="color: rgb(0, 0, 187);">$g</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">current_user</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">group_model_name</span><span style="color: rgb(0, 119, 0);">][</span><span style="color: rgb(221, 0, 0);">'id'</span><span style="color: rgb(0, 119, 0);">]&nbsp;==&nbsp;</span><span style="color: rgb(0, 0, 187);">$g&nbsp;</span><span style="color: rgb(0, 119, 0);">||
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">current_user</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">group_model_name</span><span style="color: rgb(0, 119, 0);">][</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">group_name_field</span><span style="color: rgb(0, 119, 0);">]&nbsp;==&nbsp;</span><span style="color: rgb(0, 0, 187);">$g
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//&nbsp;Our&nbsp;Authenticated&nbsp;user&nbsp;matches&nbsp;a&nbsp;group!&nbsp;TRUE
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">return&nbsp;</span><span style="color: rgb(0, 0, 187);">true</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}else{
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//HasAndBelongToMany&nbsp;relationship.&nbsp;we&nbsp;search&nbsp;the&nbsp;other&nbsp;way&nbsp;around...
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">foreach(</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">current_user</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">group_model_name</span><span style="color: rgb(0, 119, 0);">]&nbsp;as&nbsp;</span><span style="color: rgb(0, 0, 187);">$g</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">in_array</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$g</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'id'</span><span style="color: rgb(0, 119, 0);">],</span><span style="color: rgb(0, 0, 187);">$groups</span><span style="color: rgb(0, 119, 0);">)&nbsp;||
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">in_array</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$g</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">group_name_field</span><span style="color: rgb(0, 119, 0);">],</span><span style="color: rgb(0, 0, 187);">$groups</span><span style="color: rgb(0, 119, 0);">)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//&nbsp;Our&nbsp;Authenticated&nbsp;user&nbsp;matches&nbsp;a&nbsp;group!&nbsp;TRUE
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">return&nbsp;</span><span style="color: rgb(0, 0, 187);">true</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//No&nbsp;Access&nbsp;this&nbsp;time.&nbsp;FALSE
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">return&nbsp;</span><span style="color: rgb(0, 0, 187);">false</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;}
<br>
<br>&nbsp;&nbsp;function&nbsp;</span><span style="color: rgb(0, 0, 187);">getCookieInfo</span><span style="color: rgb(0, 119, 0);">(){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!</span><span style="color: rgb(0, 0, 187);">array_key_exists</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">'DarkAuth'</span><span style="color: rgb(0, 119, 0);">,</span><span style="color: rgb(0, 0, 187);">$_COOKIE</span><span style="color: rgb(0, 119, 0);">)){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//No&nbsp;cookie
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">return&nbsp;</span><span style="color: rgb(0, 0, 187);">false</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;list(</span><span style="color: rgb(0, 0, 187);">$hash</span><span style="color: rgb(0, 119, 0);">,</span><span style="color: rgb(0, 0, 187);">$data</span><span style="color: rgb(0, 119, 0);">)&nbsp;=&nbsp;</span><span style="color: rgb(0, 0, 187);">explode</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">"|||"</span><span style="color: rgb(0, 119, 0);">,</span><span style="color: rgb(0, 0, 187);">$_COOKIE</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'DarkAuth'</span><span style="color: rgb(0, 119, 0);">]);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span style="color: rgb(0, 0, 187);">$hash&nbsp;</span><span style="color: rgb(0, 119, 0);">!=&nbsp;</span><span style="color: rgb(0, 0, 187);">md5</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$data</span><span style="color: rgb(0, 119, 0);">.</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">secure_key</span><span style="color: rgb(0, 119, 0);">())){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//Cookie&nbsp;has&nbsp;been&nbsp;tampered&nbsp;with
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">return&nbsp;</span><span style="color: rgb(0, 0, 187);">false</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$crumbs&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">unserialize</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">base64_decode</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$data</span><span style="color: rgb(0, 119, 0);">));
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!</span><span style="color: rgb(0, 0, 187);">array_key_exists</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">'username'</span><span style="color: rgb(0, 119, 0);">,</span><span style="color: rgb(0, 0, 187);">$crumbs</span><span style="color: rgb(0, 119, 0);">)&nbsp;||
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;!</span><span style="color: rgb(0, 0, 187);">array_key_exists</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">'password'</span><span style="color: rgb(0, 119, 0);">,</span><span style="color: rgb(0, 0, 187);">$crumbs</span><span style="color: rgb(0, 119, 0);">)&nbsp;||
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;!</span><span style="color: rgb(0, 0, 187);">array_key_exists</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">'expiry'&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">,</span><span style="color: rgb(0, 0, 187);">$crumbs</span><span style="color: rgb(0, 119, 0);">)){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//Cookie&nbsp;doesn't&nbsp;contain&nbsp;the&nbsp;correct&nbsp;info.
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">return&nbsp;</span><span style="color: rgb(0, 0, 187);">false</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!isset(</span><span style="color: rgb(0, 0, 187);">$crumbs</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'expiry'</span><span style="color: rgb(0, 119, 0);">])&nbsp;||&nbsp;</span><span style="color: rgb(0, 0, 187);">$crumbs</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'expiry'</span><span style="color: rgb(0, 119, 0);">]&nbsp;&lt;=&nbsp;</span><span style="color: rgb(0, 0, 187);">time</span><span style="color: rgb(0, 119, 0);">()){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//Cookie&nbsp;is&nbsp;out&nbsp;of&nbsp;date!
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">return&nbsp;</span><span style="color: rgb(0, 0, 187);">false</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//All&nbsp;checks&nbsp;passed,&nbsp;cookie&nbsp;is&nbsp;genuine.&nbsp;remove&nbsp;expiry&nbsp;time&nbsp;and&nbsp;return
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">unset(</span><span style="color: rgb(0, 0, 187);">$crumbs</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'expiry'</span><span style="color: rgb(0, 119, 0);">]);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: rgb(0, 0, 187);">$crumbs</span><span style="color: rgb(0, 119, 0);">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br>&nbsp;&nbsp;}
<br>&nbsp;&nbsp;
<br>&nbsp;&nbsp;function&nbsp;</span><span style="color: rgb(0, 0, 187);">setCookieInfo</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$data</span><span style="color: rgb(0, 119, 0);">,</span><span style="color: rgb(0, 0, 187);">$expiry</span><span style="color: rgb(0, 119, 0);">=</span><span style="color: rgb(0, 0, 187);">0</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span style="color: rgb(0, 0, 187);">$data&nbsp;</span><span style="color: rgb(0, 119, 0);">===&nbsp;</span><span style="color: rgb(0, 0, 187);">false</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//remove&nbsp;cookie!
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$cookie&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">false</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$expiry&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">100</span><span style="color: rgb(0, 119, 0);">;&nbsp;</span><span style="color: rgb(255, 128, 0);">//should&nbsp;be&nbsp;in&nbsp;the&nbsp;past&nbsp;enough!
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">}else{
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$serial&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">base64_encode</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">serialize</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$data</span><span style="color: rgb(0, 119, 0);">));
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$hash&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">md5</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$serial</span><span style="color: rgb(0, 119, 0);">.</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">secure_key</span><span style="color: rgb(0, 119, 0);">());
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$cookie&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">$hash</span><span style="color: rgb(0, 119, 0);">.</span><span style="color: rgb(221, 0, 0);">"|||"</span><span style="color: rgb(0, 119, 0);">.</span><span style="color: rgb(0, 0, 187);">$serial</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span style="color: rgb(0, 0, 187);">$_SERVER</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'SERVER_NAME'</span><span style="color: rgb(0, 119, 0);">]==</span><span style="color: rgb(221, 0, 0);">'localhost'</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$domain&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">null</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}else{
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$domain&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(221, 0, 0);">'.'</span><span style="color: rgb(0, 119, 0);">.</span><span style="color: rgb(0, 0, 187);">$_SERVER</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'SERVER_NAME'</span><span style="color: rgb(0, 119, 0);">];
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: rgb(0, 0, 187);">setcookie</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">'DarkAuth'</span><span style="color: rgb(0, 119, 0);">,&nbsp;</span><span style="color: rgb(0, 0, 187);">$cookie</span><span style="color: rgb(0, 119, 0);">,&nbsp;</span><span style="color: rgb(0, 0, 187);">$expiry</span><span style="color: rgb(0, 119, 0);">,&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">controller</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">base</span><span style="color: rgb(0, 119, 0);">,&nbsp;</span><span style="color: rgb(0, 0, 187);">$domain</span><span style="color: rgb(0, 119, 0);">);
<br>&nbsp;&nbsp;}
<br>
<br>&nbsp;&nbsp;function&nbsp;</span><span style="color: rgb(0, 0, 187);">authenticate_from_post</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$data</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">from_post&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">true</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">authenticate</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$data</span><span style="color: rgb(0, 119, 0);">);
<br>&nbsp;&nbsp;}
<br>&nbsp;&nbsp;function&nbsp;</span><span style="color: rgb(0, 0, 187);">authenticate_from_session</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$data</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">from_session&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">true</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">authenticate</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$data</span><span style="color: rgb(0, 119, 0);">);
<br>&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: rgb(0, 0, 187);">authenticate_from_cookie</span><span style="color: rgb(0, 119, 0);">(){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">from_cookie&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">true</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">authenticate</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">getCookieInfo</span><span style="color: rgb(0, 119, 0);">());
<br>&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;
<br>&nbsp;&nbsp;function&nbsp;</span><span style="color: rgb(0, 0, 187);">authenticate</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$data</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span style="color: rgb(0, 0, 187);">$data&nbsp;</span><span style="color: rgb(0, 119, 0);">===&nbsp;</span><span style="color: rgb(0, 0, 187);">false</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">destroyData</span><span style="color: rgb(0, 119, 0);">();
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: rgb(0, 0, 187);">false</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">from_session&nbsp;</span><span style="color: rgb(0, 119, 0);">||&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">from_cookie</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$hashed_password&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">$data</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'password'</span><span style="color: rgb(0, 119, 0);">];
<br>&nbsp;&nbsp;&nbsp;&nbsp;}else{
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$hashed_password&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">hasher</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$data</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'password'</span><span style="color: rgb(0, 119, 0);">]);
<br>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;switch(</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">user_name_case_folding</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;</span><span style="color: rgb(221, 0, 0);">'lower'</span><span style="color: rgb(0, 119, 0);">:
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$data</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'username'</span><span style="color: rgb(0, 119, 0);">]&nbsp;=&nbsp;</span><span style="color: rgb(0, 0, 187);">strtolower</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$data</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'username'</span><span style="color: rgb(0, 119, 0);">]);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;</span><span style="color: rgb(221, 0, 0);">'upper'</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$data</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'username'</span><span style="color: rgb(0, 119, 0);">]&nbsp;=&nbsp;</span><span style="color: rgb(0, 0, 187);">strtoupper</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$data</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'username'</span><span style="color: rgb(0, 119, 0);">]);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default:&nbsp;break;
<br>&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$conditions&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;array(
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">user_model_name</span><span style="color: rgb(0, 119, 0);">.</span><span style="color: rgb(221, 0, 0);">"."</span><span style="color: rgb(0, 119, 0);">.</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">user_name_field&nbsp;</span><span style="color: rgb(0, 119, 0);">=&gt;&nbsp;</span><span style="color: rgb(0, 0, 187);">$data</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'username'</span><span style="color: rgb(0, 119, 0);">],
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">user_model_name</span><span style="color: rgb(0, 119, 0);">.</span><span style="color: rgb(221, 0, 0);">"."</span><span style="color: rgb(0, 119, 0);">.</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">user_pass_field&nbsp;</span><span style="color: rgb(0, 119, 0);">=&gt;&nbsp;</span><span style="color: rgb(0, 0, 187);">$hashed_password
<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">);
<br>&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">user_live_field</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$field&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">user_model_name</span><span style="color: rgb(0, 119, 0);">.</span><span style="color: rgb(221, 0, 0);">"."</span><span style="color: rgb(0, 119, 0);">.</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">user_live_field</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$conditions</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(0, 0, 187);">$field</span><span style="color: rgb(0, 119, 0);">]&nbsp;=&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">user_live_value</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;};
<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$check&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">controller</span><span style="color: rgb(0, 119, 0);">-&gt;{</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">user_model_name</span><span style="color: rgb(0, 119, 0);">}-&gt;</span><span style="color: rgb(0, 0, 187);">find</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$conditions</span><span style="color: rgb(0, 119, 0);">);
<br>&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span style="color: rgb(0, 0, 187);">$check</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">Session</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">write</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">secure_key</span><span style="color: rgb(0, 119, 0);">(),</span><span style="color: rgb(0, 0, 187);">$check</span><span style="color: rgb(0, 119, 0);">);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">allow_cookie&nbsp;</span><span style="color: rgb(0, 119, 0);">&amp;&amp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//check&nbsp;we're&nbsp;allowing&nbsp;cookies
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">from_post&nbsp;</span><span style="color: rgb(0, 119, 0);">&amp;&amp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//check&nbsp;this&nbsp;was&nbsp;a&nbsp;posted&nbsp;login&nbsp;attempt.
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">array_key_exists</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">'remember_me'</span><span style="color: rgb(0, 119, 0);">,</span><span style="color: rgb(0, 0, 187);">$data</span><span style="color: rgb(0, 119, 0);">)&nbsp;&amp;&amp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//check&nbsp;they&nbsp;where&nbsp;given&nbsp;the&nbsp;option!
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$data</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'remember_me'</span><span style="color: rgb(0, 119, 0);">]&nbsp;==&nbsp;</span><span style="color: rgb(0, 0, 187);">true&nbsp;</span><span style="color: rgb(255, 128, 0);">//check&nbsp;they&nbsp;WANT&nbsp;a&nbsp;cookie&nbsp;set
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//&nbsp;set&nbsp;our&nbsp;cookie!
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">if(</span><span style="color: rgb(0, 0, 187);">array_key_exists</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">'cookie_expiry'</span><span style="color: rgb(0, 119, 0);">,</span><span style="color: rgb(0, 0, 187);">$data</span><span style="color: rgb(0, 119, 0);">)){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">cookie_expiry&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">$data</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'cookie_expiry'</span><span style="color: rgb(0, 119, 0);">];
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}else{
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">cookie_expiry</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span style="color: rgb(0, 0, 187);">strtotime</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">cookie_expiry</span><span style="color: rgb(0, 119, 0);">)&nbsp;&lt;=&nbsp;</span><span style="color: rgb(0, 0, 187);">time</span><span style="color: rgb(0, 119, 0);">()){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//&nbsp;Session&nbsp;cookie?&nbsp;might&nbsp;as&nbsp;well&nbsp;not&nbsp;set&nbsp;at&nbsp;all...
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 119, 0);">}else{
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$expiry&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">strtotime</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">cookie_expiry</span><span style="color: rgb(0, 119, 0);">);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">setCookieInfo</span><span style="color: rgb(0, 119, 0);">(array(</span><span style="color: rgb(221, 0, 0);">'username'</span><span style="color: rgb(0, 119, 0);">=&gt;</span><span style="color: rgb(0, 0, 187);">$data</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'username'</span><span style="color: rgb(0, 119, 0);">],&nbsp;</span><span style="color: rgb(221, 0, 0);">'password'</span><span style="color: rgb(0, 119, 0);">=&gt;</span><span style="color: rgb(0, 0, 187);">$hashed_password</span><span style="color: rgb(0, 119, 0);">,&nbsp;</span><span style="color: rgb(221, 0, 0);">'expiry'</span><span style="color: rgb(0, 119, 0);">=&gt;</span><span style="color: rgb(0, 0, 187);">$expiry</span><span style="color: rgb(0, 119, 0);">),&nbsp;</span><span style="color: rgb(0, 0, 187);">$expiry</span><span style="color: rgb(0, 119, 0);">);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">current_user&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">$check</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: rgb(0, 0, 187);">true</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;}else{
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">destroyData</span><span style="color: rgb(0, 119, 0);">();
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: rgb(0, 0, 187);">false</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;}
<br>
<br>&nbsp;&nbsp;function&nbsp;</span><span style="color: rgb(0, 0, 187);">getUserInfo</span><span style="color: rgb(0, 119, 0);">(){
<br>&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">current_user</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">user_model_name</span><span style="color: rgb(0, 119, 0);">];
<br>&nbsp;&nbsp;}
<br>&nbsp;&nbsp;function&nbsp;</span><span style="color: rgb(0, 0, 187);">getAllUserInfo</span><span style="color: rgb(0, 119, 0);">(){
<br>&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">current_user</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;}
<br>
<br>&nbsp;&nbsp;function&nbsp;</span><span style="color: rgb(0, 0, 187);">destroyData</span><span style="color: rgb(0, 119, 0);">(){
<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">Session</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">delete</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">secure_key</span><span style="color: rgb(0, 119, 0);">());
<br>&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">allow_cookie</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">setcookieInfo</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">false</span><span style="color: rgb(0, 119, 0);">);&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">current_user&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">null</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;}
<br>
<br>&nbsp;&nbsp;function&nbsp;</span><span style="color: rgb(0, 0, 187);">logout</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$redirect</span><span style="color: rgb(0, 119, 0);">=</span><span style="color: rgb(0, 0, 187);">false</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">destroyData</span><span style="color: rgb(0, 119, 0);">();
<br>&nbsp;&nbsp;&nbsp;&nbsp;if(!</span><span style="color: rgb(0, 0, 187);">$redirect</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$redirect&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">logout_page</span><span style="color: rgb(0, 119, 0);">;
<br>&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">controller</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">redirect</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$redirect</span><span style="color: rgb(0, 119, 0);">);
<br>&nbsp;&nbsp;&nbsp;&nbsp;exit();
<br>&nbsp;&nbsp;}
<br>
<br>&nbsp;&nbsp;function&nbsp;</span><span style="color: rgb(0, 0, 187);">getUserInfoFromSessionOrCookie</span><span style="color: rgb(0, 119, 0);">(){
<br>&nbsp;&nbsp;&nbsp;&nbsp;if(&nbsp;!empty(</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">current_user</span><span style="color: rgb(0, 119, 0);">)&nbsp;){&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: rgb(0, 0, 187);">false</span><span style="color: rgb(0, 119, 0);">;&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">Session</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">valid</span><span style="color: rgb(0, 119, 0);">()&nbsp;&amp;&amp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">Session</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">check</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">secure_key</span><span style="color: rgb(0, 119, 0);">())&nbsp;){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">current_user&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">Session</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">read</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">secure_key</span><span style="color: rgb(0, 119, 0);">());
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">authenticate_from_session</span><span style="color: rgb(0, 119, 0);">(array(
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(221, 0, 0);">'username'&nbsp;</span><span style="color: rgb(0, 119, 0);">=&gt;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">current_user</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">user_model_name</span><span style="color: rgb(0, 119, 0);">][</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">user_name_field</span><span style="color: rgb(0, 119, 0);">],
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(221, 0, 0);">'password'&nbsp;</span><span style="color: rgb(0, 119, 0);">=&gt;&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">current_user</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">user_model_name</span><span style="color: rgb(0, 119, 0);">][</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">user_pass_field</span><span style="color: rgb(0, 119, 0);">],
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;));
<br>&nbsp;&nbsp;&nbsp;&nbsp;}elseif(</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">allow_cookie</span><span style="color: rgb(0, 119, 0);">){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: rgb(0, 0, 187);">$this</span><span style="color: rgb(0, 119, 0);">-&gt;</span><span style="color: rgb(0, 0, 187);">authenticate_from_cookie</span><span style="color: rgb(0, 119, 0);">();
<br>&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;}
<br>}
<br></span><span style="color: rgb(0, 0, 187);">?&gt;</span>
</span>
</code><br>
<br>
Got all that... good now let's set it up!
		</div>
			<p class="right">
							</p>
						<p class="right">
					<a href="http://bakery.cakephp.org/leafs/view/42">page 3: 5 Steps to Setup (well, maybe 6)</a>				</p>
				
			
	</div>
</div>
<!-- comments -->
<!-- /comments -->

<!-- add comments -->
		<a name="addCommentAnchor"></a>
					<div id="addComment">
				<h3>
					<a href="http://bakery.cakephp.org/comments/add/617#comments" id="link2077999654" onclick=" return false;">Login to Submit a Comment</a><script type="text/javascript">Event.observe('link2077999654', 'click', function(event) { new Ajax.Updater('addComment','/comments/add/617#comments', {asynchronous:true, evalScripts:true, onLoading:function(request) {Effect.Appear('loader');}, onComplete:function(request, json) {Effect.Appear('addComment');Effect.Fade('loader'); $('addCommentAnchor').scrollTo();}, requestHeaders:['X-Update', 'addComment']}) }, false);</script>					<em id="loader" style="display: none;">Loading...</em>
				</h3>
			</div>
			<div class="clear"><!----></div>
		<!-- /add comments -->
			
			<div class="clear"><!----></div>
		</div> <!-- #content -->
	</div> <!-- #container -->
	<div id="footer-container">
		<div id="footer">
			<div class="latest-container">
		<div class="latest articles">
		<h4>Latest Articles</h4>
		
		<ul>
							<li><a href="http://bakery.cakephp.org/articles/view/tidy-output-filtering">Tidy Output Filtering</a></li>
							<li><a href="http://bakery.cakephp.org/articles/view/vendor-branching">Vendor Branching</a></li>
							<li><a href="http://bakery.cakephp.org/articles/view/gallery2-api-and-cakephp-component">Rolling you own Gallery2 component</a></li>
							<li><a href="http://bakery.cakephp.org/articles/view/maintaining-an-application-independant-code-library">Maintaining an Application-independant Code Library</a></li>
							<li><a href="http://bakery.cakephp.org/articles/view/marinas-and-yacht-sales-web-site">Marinas and Yacht Sales Web Site</a></li>
					</ul>
	</div>
		<div class="latest code">
		<h4>Latest Code</h4>
		
		<ul>
							<li><a href="http://bakery.cakephp.org/articles/view/bindable-behavior-control-your-model-bindings">Bindable Behavior: control your model bindings</a></li>
							<li><a href="http://bakery.cakephp.org/articles/view/increment-behavior">Increment Behavior</a></li>
							<li><a href="http://bakery.cakephp.org/articles/view/twitter-component">Twitter Component</a></li>
							<li><a href="http://bakery.cakephp.org/articles/view/easy-ajax-pagination-using-jquery">Easy AJAX Pagination Using JQuery</a></li>
							<li><a href="http://bakery.cakephp.org/articles/view/open-flash-chart-helper-draw-charts-the-cake-way">Open Flash Chart Helper: draw charts the Cake way</a></li>
					</ul>
	</div>
		<div class="latest news">
		<h4>Latest News</h4>
		
		<ul>
							<li><a href="http://bakery.cakephp.org/articles/view/cakephp-1-2-stable-coming-soon">CakePHP 1.2 stable coming soon</a></li>
							<li><a href="http://bakery.cakephp.org/articles/view/after-3-years-looking-back-and-moving-ahead">After 3 years, looking back and moving ahead</a></li>
							<li><a href="http://bakery.cakephp.org/articles/view/new-year-new-beta">New Year, New Beta</a></li>
							<li><a href="http://bakery.cakephp.org/articles/view/cakefest-2008-02-06-orlando-fl">CakeFest : 2008-02-06, Orlando FL [updated]</a></li>
							<li><a href="http://bakery.cakephp.org/articles/view/new-cakephp-releases">New CakePHP Releases</a></li>
					</ul>
	</div>
		<div class="latest comments">
		<h4>Latest Comments</h4>
		
		<ul>
							<li><a href="http://bakery.cakephp.org/articles/view/testing-models-with-cakephp-1-2-test-suite#comment-2358">Limit the no of records imported</a></li>
							<li><a href="http://bakery.cakephp.org/articles/view/tidy-output-filtering#comment-2355">CakePHP limitation</a></li>
							<li><a href="http://bakery.cakephp.org/articles/view/tree-helper-1#comment-2353">Tree Helper updates v1 70</a></li>
							<li><a href="http://bakery.cakephp.org/articles/view/vendor-branching#comment-2352">What is conflicting</a></li>
							<li><a href="http://bakery.cakephp.org/articles/view/10-confusions-with-their-solutions-before-you-start-using-cakephp#comment-2351">Errors when building Blog tutorial</a></li>
					</ul>
	</div>
</div>			<div class="copyright">
		   	<span class="left">
		   		<a href="http://cakefoundation.org/">© 2006 Cake Software Foundation</a>		   	</span>
	 	    <a href="http://www.w3c.org/" target="_new">
	      	<img src="Authenticate_from_cookie_files/w3c_css.png" alt="valid css" border="0">	      </a>
	      <a href="http://www.w3c.org/" target="_new">
	      	<img src="Authenticate_from_cookie_files/w3c_xhtml10.png" alt="valid xhtml" border="0">	      </a>
	      <a href="http://www.cakephp.org/" target="_new">
	   			<img src="Authenticate_from_cookie_files/cake.png" alt="CakePHP : Rapid Development Framework" border="0">	   	  </a>
	   	 </div>
    </div>
	</div>
</body></html>